import java.util.List;


public class WidrowHoffNeuron extends LinearNeuron {
	
	public WidrowHoffNeuron(String weights) {
		super(weights);
	}
	
	public WidrowHoffNeuron(int weightsNum) {
		super(weightsNum);
	}

	
	public String learn(Float targetValue, NeuronLayer inputLayer) {

		if(inputLayer.type == NeuronLayer.KOHONEN) {
			((KohonenLayer)inputLayer).normalizeForWidrow();
		}
		
		List<Neuron> inputNeurons = inputLayer.getNeurons();
		System.out.println(weights);
		for(int i=0; i< weights.size(); i++){
			float oldWeight = weights.get(i);
			float a = inputLayer.getA();
			float currentValue = (float) 0.0;
			System.out.println("target val: "+targetValue);
			for(int j=0; j< weights.size(); j++){
				currentValue += weights.get(j)*inputNeurons.get(j).getOutput();
			}
			float inputValue = inputLayer.getNeurons().get(i).getOutput();
			System.out.println("set "+i+" weight, old weight: "+oldWeight+" target: "+targetValue+" current "+currentValue+" input "+inputValue+" new "+(oldWeight + a * (targetValue - currentValue)* inputValue));
			setWeight(i, oldWeight + a * (targetValue - currentValue)* inputValue);
		}
		return "";
		
	}

}
